﻿using System.Security.AccessControl;

namespace System.IO
{
    public class DefaultFileInfo : DefaultFileSystemInfo, IFileInfo
    {
        private readonly FileInfo _fileInfo;

        public DefaultFileInfo(FileInfo fileInfo)
            : base(fileInfo)
        {
            _fileInfo = fileInfo;
        }

        public FileSecurity GetAccessControl()
        {
            return _fileInfo.GetAccessControl();
        }

        public FileSecurity GetAccessControl(AccessControlSections includeSections)
        {
            return _fileInfo.GetAccessControl(includeSections);
        }

        public void SetAccessControl(FileSecurity fileSecurity)
        {
            _fileInfo.SetAccessControl(fileSecurity);
        }

        public StreamReader OpenText()
        {
            return _fileInfo.OpenText();
        }

        public StreamWriter CreateText()
        {
            return _fileInfo.CreateText();
        }

        public StreamWriter AppendText()
        {
            return _fileInfo.AppendText();
        }

        public IFileInfo CopyTo(string destFileName)
        {
            return new DefaultFileInfo(_fileInfo.CopyTo(destFileName));
        }

        public IFileInfo CopyTo(string destFileName, bool overwrite)
        {
            return new DefaultFileInfo(_fileInfo.CopyTo(destFileName, overwrite));
        }

        public Stream Create()
        {
            return _fileInfo.Create();
        }

        public void Decrypt()
        {
            _fileInfo.Decrypt();
        }

        public void Encrypt()
        {
            _fileInfo.Encrypt();
        }

        public Stream Open(FileMode mode)
        {
            return _fileInfo.Open(mode);
        }

        public Stream Open(FileMode mode, FileAccess access)
        {
            return _fileInfo.Open(mode, access);
        }

        public Stream Open(FileMode mode, FileAccess access, FileShare share)
        {
            return _fileInfo.Open(mode, access, share);
        }

        public Stream OpenRead()
        {
            return _fileInfo.OpenRead();
        }

        public Stream OpenWrite()
        {
            return _fileInfo.OpenWrite();
        }

        public void MoveTo(string destFileName)
        {
            _fileInfo.MoveTo(destFileName);
        }

        public IFileInfo Replace(string destinationFileName, string destinationBackupFileName)
        {
            return new DefaultFileInfo(_fileInfo.Replace(destinationFileName, destinationBackupFileName));
        }

        public IFileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors)
        {
            return new DefaultFileInfo(_fileInfo.Replace(destinationFileName, destinationBackupFileName, ignoreMetadataErrors));
        }

        public long Length
        {
            get { return _fileInfo.Length; }
        }

        public string DirectoryName
        {
            get { return _fileInfo.DirectoryName; }
        }

        public IDirectoryInfo Directory
        {
            get { return new DefaultDirectoryInfo(_fileInfo.Directory); }
        }

        public bool IsReadOnly
        {
            get { return _fileInfo.IsReadOnly; }
            set { _fileInfo.IsReadOnly = value; }
        }
    }
}